<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>教师页面</title>
    <script src="../../js/vue.js"></script>
    <script src="../../element-ui/lib/index.js"></script>
    <link rel="stylesheet" href="../../element-ui/lib/theme-chalk/index.css">
    <script src="../../js/axios-0.18.0.js"></script>


    <style>
        .el-header {
            background-color: #B3C0D1;
            color: #333;
            text-align: center;
            line-height: 60px;
        }

        .el-aside {
            background-color: #D3DCE6;
            color: #333;
            text-align: center;
            line-height: 640px;
        }

        .el-main {
            background-color: #E9EEF3;
            color: #333;
            text-align: center;
            line-height: 2px;
        }

        body > .el-container {
            margin-bottom: 40px;
        }


        .el-container:nth-child(7) .el-aside {
            line-height: 320px;
        }
    </style>
    <style>
        .el-table .warning-row {
            background: oldlace;
        }

        .el-table .success-row {
            background: #f0f9eb;
        }
    </style>
</head>
<body>
<div id="app">

    <el-container>
        <el-container>
            <table>
                <el-header>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <span>账号:</span>
                    <span>{{this.rightData.adm_username}}</span>
                    <el-button type="primary" class="el-icon-switch-button" circle @click="admQuit"></el-button>
                </el-header>
            </table>
            <el-main>
                <template>
                    <el-table
                            :data="tableData"
                            style="width: 100%"
                            :row-class-name="tableRowClassName"
                            @selection-change="handleSelectionChange">
                        <el-table-column
                                type="selection"
                                width="55">
                        </el-table-column>
                        <el-table-column
                                type="index"
                                width="50">
                        </el-table-column>
                        <el-table-column
                                prop="stu_nikename"
                                label="学生姓名"
                                align="center"
                                width="180">
                        </el-table-column>
                        <el-table-column
                                prop="stu_username"
                                align="center"
                                label="账号">
                        </el-table-column>
                            <!---------------------------------操作按钮------------------------------------->
                            <el-table-column label="操作" align="center">
                                <template slot-scope="scope" align="center">
                                    <el-button
                                            type="primary"
                                            round
                                            @click="handleDelete(scope.row.stu_username)">学生信息详情
                                    </el-button>
                                </template>
                            </el-table-column>

                    </el-table>
                </template>
            </el-main>
        </el-container>
    </el-container>
</div>
<script>
    new Vue({
        el: "#app",
        data: {
            rightData: {
                adm_username: '',
                adm_password: ''
            },
            tableData: [{
                stu_nikename:'',
                stu_username:'',
            }],
            multipleSelection: [],
            stu_username:'',
        },
        methods: {
            handleDelete(stu_username) {
                console.log(stu_username);
                this.stu_username = stu_username;
                console.log("++++++++++++++++");
                sessionStorage.setItem("studentKey", this.stu_username)
                window.requestAnimationFrame(() => {
                    window.location.href = '/page/teacher/studentInfo.html'
                })
            },
            handleSelectionChange(val) {
                console.log(val);
                this.multipleSelection = val;
            },
            tableRowClassName({row, rowIndex}) {
                if (rowIndex % 2 == 1) {
                    return 'warning-row';
                } else if (rowIndex % 2 != 1) {
                    return 'success-row';
                }
                return '';
            },
            /*右上角的按钮*/
            admQuit() {
                sessionStorage.removeItem("username");
                sessionStorage.removeItem("pwd");
                window.requestAnimationFrame(() => {
                    window.location.href = '/index.html'
                })
            },
            shezhi() {
                this.rightData.adm_username = sessionStorage.getItem("username")
                this.rightData.adm_password = sessionStorage.getItem("pwd")
            },
        },
        created() {
            this.shezhi();
            axios.post("/tea/findStu").then(resp => {
                console.log(resp);
                if (resp.data.code == 1) {
                    this.tableData = resp.data.data
                } else {
                    this.$notify({type: 'error', message: '查询失败！'});
                }
            })
        }
    });
</script>
</body>
</html>